class Solution {
public:
    int fib(int n) {
        if(n==0) return 0;
        if(n==1) return 1;
        int f0=0,f1=1;
        int fn;
        while(n>=2){
            fn=(f0+f1)%1000000007;
            f0=f1;
            f1=fn;
            n--;
        }
        return fn;
    }
};